package cn.szzsi.service;

import cn.szzsi.common.model.Member;
import cn.szzsi.common.model.OrderItem;
import cn.szzsi.common.model.Product;

import java.util.Date;

/**
 * Created by zhengy on 2017/3/14.
 */
public class OrderItemService {
    public static final OrderItemService service=new OrderItemService();

    /**
     * 商品项业务类
     * @param product
     * @param quantity
     * @param orderId
     * @param member
     */
    public void saveOrderItem(Product product, Integer quantity, String orderId, Member member){
        OrderItem orderItem = new OrderItem();
        orderItem.set("productSn",product.getStr("productSn"));
        orderItem.set("productName",product.getStr("name"));
        orderItem.set("productPrice",product.getPreferentialPrice(member));
        orderItem.set("productQuantity",quantity);
        orderItem.set("deliveryQuantity",0);
        orderItem.set("totalDeliveryQuantity",0);
        orderItem.set("productHtmlFilePath",product.getStr("htmlFilePath"));
        orderItem.set("order_id",orderId);
        orderItem.set("product_id",product.getStr("id"));
        orderItem.save(orderItem);
    }

}
